<template>
  <div>
    <input id="checkall" type="checkbox" v-model="isSelected" @change="selectedAll(isSelected)" />
    <div @click="changeval()">{{demo}}</div>
    <slot name="center" :user="user">
      <h3>{{ user.firstName }}</h3>
    </slot>
    <slot name="footer" :user="user">
      <h3>{{ user.lastName }}</h3>
    </slot>
    <div @click="changeProvide">测试provide</div>
    <p>{{prodate}}</p>
    <Sun></Sun>
  </div>
</template>
<script>
import Sun from './sun'
export default {
  name: "child",
  components:{Sun},
  inject:['dataInfo'],
  props: {
    fatherMethod: {
      type: Function,
      default: null
    }
  },
  data() {
    return {
      isSelected: false,
      demo: 0,
      user: {
        lastName: "哈哈555哈",
        firstName:this.dataInfo
      },
      prodate:this.dataInfo
    };
  },
  methods: {
    //   selectedAll(val){
    //     this.$emit('cartBottomStatus',val);
    //   }
    selectedAll(val) {
      this.$parent.$emit("cartBottomStatus", val);
    },
    changeval() {
      this.demo = 2;
      //this.$parent.fatherMethod();
      //this.$emit('fatherMethod')
      if (this.fatherMethod) {
        this.fatherMethod();
      }
    },
    childMethod() {
      console.log("触发了子组件事件");
    },
    changeProvide(){
      this.prodate='123'
    }
  }
};
</script>
<style>
</style>
